import os


print(os.getcwd()+os.sep+'data'+os.sep+'test.dat')
print(os.listdir(path='.'))
print(os.listdir(os.getcwd()+os.sep))
os.mkdir(os.getcwd()+os.sep+'newdir')
os.makedirs(os.getcwd()+os.sep+'subdir1'+os.sep+'subdir2')
os.rmdir(os.getcwd()+os.sep+'newdir')
os.rmdir(os.getcwd()+os.sep+'subdir1'+os.sep+'subdir2')
os.rmdir(os.getcwd()+os.sep+'subdir1')
print(os.path.abspath('..'))
print(os.path.abspath('DLLs'))
print(os.path.dirname('D:\\Python\\Python37\\LICENSE.txt'))
print(os.path.basename('D:\\Python\\Python37\\LICENSE.txt'))
print(os.path.split(os.getcwd()))
print(os.path.join("d:","test"))

dir = os.getcwd()
file = dir + os.sep + 'test.txt'
print("dir是文件：{}".format(os.path.isfile(dir)))
print("file是文件：{}".format(os.path.isfile(file)))

dir = os.getcwd()
file = dir + os.sep + 'LICENSE.txt'
print("dir是目录：{}".format(os.path.isdir(dir)))
print("file是目录：{}".format(os.path.isdir(file)))

dir = os.getcwd()
file = dir + os.sep + 'demo.txt'
print("file 路径存在：{}".format(os.path.exists(file)))

dir = os.getcwd()
file = 'demo.txt'
print("file 是绝对路径：{}".format(os.path.isabs(file)))

# for i in range(3):  # 循环3次
#     try:
#         num = int(input('请输入一个数字：'))
#         print(10 / num)
#     except ValueError:
#         print('值错误！')
#     except:
#         print('其他异常！')
#
# for i in range(3):  # 循环3次
#     try:
#         num = int(input('请输入一个数字： '))
#         print(10 / num)
#     except ValueError:
#         print('值错误！ ')
#     except:
#         print('其他异常！')
#     else:
#         print('else子句被执行！ ')
#
#
# for i in range(3):  # 循环3次
#     try:
#         num = int(input('请输入一个数字： '))
#         print(10 / num)
#     except ValueError:
#         print('值错误！ ')
#     except:
#         print('其他异常！')
#     finally:
#         print('finally子句被执行！ ')
class ScoreError(BaseException):

    def __init__(self, msg):
        self.msg = msg
    def __str__(self):
        return repr(self.msg)
if __name__ == '__main__':
    for i in range(2):
        try:
            score = int(input("请输入一个成绩"));
            if score < 0 or score > 100:
                raise ScoreError('输入成绩为{}，成绩应该在10-100之间'.format(score))
            print('输入成绩为%d' % score)

        except ScoreError as e:
            print('分数错误',e)
